package cn.zhouchao.controller;

import cn.zhouchao.User;
import cn.zhouchao.feign.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

@RestController
@RequestMapping("/pay")
public class PayController {
    @Autowired
    private UserService userService;
    @GetMapping("/{id}")
    public User getUser(@PathVariable("id") Long id) {
        User user = userService.getUser(id);
        // 业务代码(如果是熔断了就响应user，不是熔断就还需要做以下业务处理)
        if (user.getId().equals(-1L)) {
            System.out.println("熔断了");
           return user;
        }
        System.out.println("111");
        System.out.println("222");
        System.out.println("333");
        System.out.println("444");
        System.out.println("555");
        return userService.getUser(id); // 使用过openFeign调用user服务
    }
}
